package j2025.j02;

import j2024.j202407.ListNode;

/**
 * @Author 猫大仙
 */
class ListNode1 {
     int val;
    ListNode1 next;
     ListNode1() {}
     ListNode1(int val) { this.val = val; }
     ListNode1(int val, ListNode1 next) { this.val = val; this.next = next; }
 }
public class j0227 {
    public ListNode1 reverseList(ListNode1 head) {
        if(head==null || head.next==null) return head;
        ListNode1 newhead = reverseList(head.next);
        //(i+1)结点的下一个为i
        head.next.next = head;
        head.next = null;
        return newhead;
    }
}
